import { effect } from "./effect.js";
import { ref, toRef, toRefs, proxyRefs } from "./ref.js";
import { reactive } from "./reactive.js";

const count = ref(0);

const obj = reactive({
  foo: 1,
  bar: 2,
});

/*
  const newObj = {
    foo: 1,
    bar: 2,
  }
    非响应式数据
*/
// const newObj = {
//   ...obj,
// };

// const newObj = {
//   foo: toRef(obj, "foo"),
//   bar: toRef(obj, "bar"),
// };

// const newObj = {
//   ...toRefs(obj),
// };

/* 自动解ref，去除繁琐的.value */
const newObj = proxyRefs({
  ...toRefs(obj),
});

effect(() => {
  // console.log(count.value);
  console.log(newObj.foo);
});

// count.value++;
// newObj.foo.value++;
newObj.foo++;
